package eu.irreality.dai.gameplay.states;

import java.util.HashMap;
import java.util.Map;

/**
 * Stores the singletons of the GameStates.
 * 
 */
public class GameStateManager
{

    private static Map<String, GameState> map = new HashMap<String, GameState>();;

    private GameStateManager()
    {

    }

    public static void register(String key, GameState factory)
    {
	map.put(key, factory);
    }

    public static GameState getState(String key)
    {

	try
	{
	    if (map.get(key) == null)
		Class.forName("eu.irreality.dai.gameplay.states." + key);
	} catch (ClassNotFoundException e)
	{
	    e.printStackTrace();
	}

	return map.get(key);
    }

}
